<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
  <title>Promise</title>
  <style type="text/css">
  * {
        padding: 0;
        margin: 0;
    }
    </style>
</head>
<body>
   <div class="box">
     <h2>Promise</h2>
   </div>
  <script src="index.js"></script>
  <script src="php/ajax.js"></script>
  <script type="text/javascript">
 
class User {
  constructor(id) {
    this.id = id;
  }
  then(resolve, reject) {
    resolve(ajax(`http://localhost:8888/php/houdunren.php?id=${this.id}`));
  }
}
new Promise((resolve, reject) => {
  resolve(ajax(`http://localhost:8888/php/user.php?name=向军`));
})
.then(user => {
  return new User(user.id);
})
.then(lessons => {
  console.log(lessons);
});


  </script>
</body>
</html>